package cvut.cz.via.android;

import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.lang.reflect.Type;
import java.net.URI;
import java.util.ArrayList;
import java.util.HashSet;
import java.util.LinkedList;

import org.apache.http.HttpResponse;
import org.apache.http.client.HttpClient;
import org.apache.http.client.methods.HttpGet;
import org.apache.http.impl.client.DefaultHttpClient;

import com.google.gson.Gson;
import com.google.gson.reflect.TypeToken; 

import android.app.ListActivity;
import android.content.Intent;
import android.os.Bundle;
import android.util.Log;
import android.view.View;
import android.widget.ArrayAdapter;
import android.widget.ListView;
import cvut.cz.via.android.courses.Course;

public class MyCoursesActivity extends ListActivity {
	
	private LinkedList<String> ITEMS;
	private ArrayList<Course> COURSES;

	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.my_courses_activity);
		setItems();
	}

	private void setItems() {
		StudyMaterialsApplication sma = getStudyMaterialsApplication();
		ITEMS = sma.user.getSubscribedCourses();
		setListAdapter(new ArrayAdapter<String>(this, R.layout.courses_menu_item, ITEMS));
	}

	protected void onListItemClick(ListView l, View v, int position, long id) {
		StudyMaterialsApplication sma = getStudyMaterialsApplication();
		sma.subjectName = ITEMS.get(position);
		Intent intent = new Intent(MyCoursesActivity.this, ViewMaterialsActivity.class);		
		startActivity(intent);		
	}
	
	private StudyMaterialsApplication getStudyMaterialsApplication() {
		StudyMaterialsApplication sma = (StudyMaterialsApplication)getApplication();
		return sma;
	}
	
	

}
